<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./WEB-INF/includes/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">
    <script language="javascript">
        function autoinput(){
            alert("hello");
        }
    </script>
    <ui:define name="metadata">
        <f:metadata>
            <f:event type="preRenderView" listener="#{memberAdminBacking.init()}"/>
        </f:metadata>
    </ui:define>

    <ui:define name="title">
        人员管理--OfficeBoost System
    </ui:define>


    <ui:define name="content">
        <h:form>
            <font color="blue">
                <h:outputText value="查看用户"/> 
            </font>
            <hr color="#2EA6D7" width="15%" size="2" align="left"/>   

            <h:commandButton value="查看所有用户" action="#{memberAdminBacking.searchAll()}" /><br/>                   

            <h:outputLabel value="按组查看"/>                
            <h:inputText value="#{memberAdminBacking.groupname}"/>
            <h:commandButton value="查看" action="#{memberAdminBacking.searchByGroup()}"/><br/>

            <h:outputLabel value="按ID查看"/>
            <h:inputText value="#{memberAdminBacking.ID}"/>
            <h:commandButton value="查看" action="#{memberAdminBacking.searchByID()}"/>
            <br/>
            <font color="blue">
                <h:outputText value="修改权限"/> 
            </font>
            <hr color="#2EA6D7" width="15%" size="2" align="left"/>
            <h:outputLabel value="用户ID"/>
            <h:inputText value="#{memberAdminBacking.IDtest}"/>
            <h:selectOneMenu  value="#{memberAdminBacking.grouptest}" >
                        <f:selectItem itemLabel="student" itemValue="student"/>
                        <f:selectItem itemLabel="teacher" itemValue="teacher"/>
                        <f:selectItem itemLabel="student_office" itemValue="student_office"/>   
                        <f:selectItem itemLabel="education_office" itemValue="education_office"/>
                        <f:selectItem itemLabel="class_education_office" itemValue="class_education_office"/>
                        <f:selectItem itemLabel="department_leader" itemValue="department_leader"/> 
                        <f:selectItem itemLabel="school" itemValue="school"/>
                        <f:selectItem itemLabel="college_edu_office" itemValue="college_edu_office"/>
                        <f:selectItem itemLabel="college_office" itemValue="college_office"/> 
             </h:selectOneMenu>
            <h:commandButton action="#{memberAdminBacking.addToGroup(memberAdminBacking.IDtest)}" value="Add"
                             onclick="if(!confirm('Are you sure you want to add user #{memberAdminBacking.IDtest} to group #{memberAdminBacking.grouptest}?')) return false"/>
            <h:commandButton action="#{memberAdminBacking.deleteFromGroup(memberAdminBacking.IDtest)}" value="Delete"
                             onclick="if(!confirm('Are you sure you want to remove user #{memberAdminBacking.IDtest} from group #{memberAdminBacking.grouptest}?')) return false"/>
            
            <br/><hr color="#2EA6D7" width="100%" size="3" />

            <h:dataTable border="1" value="#{memberAdminBacking.userList}" var="user">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="ID"/>
                    </f:facet>
                    <h:outputText value="#{user.id}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Name"/>
                    </f:facet>
                    <h:outputText value="#{user.name}"/>                        
                </h:column>

                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Email"/>
                    </f:facet>
                    <h:outputText value="#{user.email}"/>
                </h:column>
               
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Group"/>
                    </f:facet>
                    <h:outputText value="#{user.putGroupString()}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Phone"/>
                    </f:facet>
                    <h:outputText value="#{user.phone}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Introduction"/>
                    </f:facet>
                    <h:outputText value="#{user.introduction}"/>
                </h:column>
            </h:dataTable>
        </h:form>
    </ui:define>

</ui:composition>
